﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;

namespace ThuPhiVeSinh
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        frmQuanHuyen frmQHObj;
        frmPhuongXa frmXPObj;
        frmKhuVuc frmKVObj;
        frmTuyenDuong frmTDObj;
        frmNhanVien frmNVObj;
        frmLoaiKH frmLKHObj;
        FormQuanLyKhachHang frmKHObj;
        frmCapPhatVe frmCPVObj;
        frmMauHoaDon frmMHDObj;
        frmPhanBoKhachHang frmPBKHObj;
        frmSuDung frmSDObj;
       

        public frmMain()
        {
            InitializeComponent();
       
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
        }

        private void btQuanHuyen_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmQHObj != null)
            {
                if (frmQHObj.IsDisposed)
                {
                    frmQHObj = new frmQuanHuyen();
                }
                else
                {
                    frmQHObj.Activate();
                }
            }
            else 
            {
                frmQHObj = new frmQuanHuyen();
            }
            
            frmQHObj.MdiParent = this;
            frmQHObj.Show();
        }

        private void btXaPhuong_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmXPObj != null)
            {
                if (frmXPObj.IsDisposed)
                {
                    frmXPObj = new frmPhuongXa();
                }
                else
                {
                    frmXPObj.Activate();
                }
            }
            else
            {
                frmXPObj = new frmPhuongXa();
            }

            frmXPObj.MdiParent = this;
            frmXPObj.Show();
        }

        private void btKhuVuc_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmKVObj != null)
            {
                if (frmKVObj.IsDisposed)
                {
                    frmKVObj = new frmKhuVuc();
                }
                else
                {
                    frmKVObj.Activate();
                }
            }
            else
            {
                frmKVObj = new frmKhuVuc();
            }

            frmKVObj.MdiParent = this;
            frmKVObj.Show();
        }

        private void btTuyenDuong_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmTDObj != null)
            {
                if (frmTDObj.IsDisposed)
                {
                    frmTDObj = new frmTuyenDuong();
                }
                else
                {
                    frmTDObj.Activate();
                }
            }
            else
            {
                frmTDObj = new frmTuyenDuong();
            }

            frmTDObj.MdiParent = this;
            frmTDObj.Show();
        }

        private void btNhanVien_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmNVObj != null)
            {
                if (frmNVObj.IsDisposed)
                {
                    frmNVObj = new frmNhanVien();
                }
                else
                {
                    frmNVObj.Activate();
                }
            }
            else
            {
                frmNVObj = new frmNhanVien();
            }

            frmNVObj.MdiParent = this;
            frmNVObj.Show();

        }

        private void btLoaiKH_ItemClick(object sender, ItemClickEventArgs e)
        {                   
            if (frmLKHObj != null)
            {
                if (frmLKHObj.IsDisposed)
                {
                    frmLKHObj = new frmLoaiKH();
                }
                else
                {
                    frmLKHObj.Activate();
                }
            }
            else
            {
                frmLKHObj = new frmLoaiKH();
            }

            frmLKHObj.MdiParent = this;
            frmLKHObj.Show();
           
        }

        private void btKH_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmKHObj != null)
            {
                if (frmKHObj.IsDisposed)
                {
                    frmKHObj = new FormQuanLyKhachHang();
                }
                else
                {
                    frmKHObj.Activate();
                }
            }
            else
            {
                frmKHObj = new FormQuanLyKhachHang();
            }

            frmKHObj.MdiParent = this;
            frmKHObj.Show();
        }

        private void btMauHD_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmMHDObj != null)
            {
                if (frmMHDObj.IsDisposed)
                {
                    frmMHDObj = new frmMauHoaDon();
                }
                else
                {
                    frmMHDObj.Activate();
                }
            }
            else
            {
                frmMHDObj = new frmMauHoaDon();
            }

            frmMHDObj.MdiParent = this;
            frmMHDObj.Show();
        }

        private void btPhanBoKH_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmPBKHObj != null)
            {
                if (frmPBKHObj.IsDisposed)
                {
                    frmPBKHObj = new frmPhanBoKhachHang();
                }
                else
                {
                    frmPBKHObj.Activate();
                }
            }
            else
            {
                frmPBKHObj = new frmPhanBoKhachHang();
            }

            frmPBKHObj.MdiParent = this;
            frmPBKHObj.Show();
        }

        private void btCapPhat_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmCPVObj != null)
            {
                if (frmCPVObj.IsDisposed)
                {
                    frmCPVObj = new frmCapPhatVe();
                }
                else
                {
                    frmCPVObj.Activate();
                }
            }
            else
            {
                frmCPVObj = new frmCapPhatVe();
            }

            frmCPVObj.MdiParent = this;
            frmCPVObj.Show();
        }

        private void btSuDungVe_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (frmSDObj != null)
            {
                if (frmSDObj.IsDisposed)
                {
                    frmSDObj = new frmSuDung();
                }
                else
                {
                    frmSDObj.Activate();
                }
            }
            else
            {
                frmSDObj = new frmSuDung();
            }

            frmSDObj.MdiParent = this;
            frmSDObj.Show();
        }    
        
    }
}